$OpenBSD: patch-src_modules_perl_Connection_xs,v 1.2 2012/06/13 12:41:14 okan Exp $
--- src/modules/perl/Connection.xs.orig	Fri Mar 30 07:12:42 2007
+++ src/modules/perl/Connection.xs	Wed Dec  5 17:41:08 2007
@@ -23,8 +23,8 @@ BOOT: 
   
 #  /* Who is the client? */
   
-#  struct sockaddr_in local_addr; /* local address */
-#  struct sockaddr_in remote_addr;/* remote address */
+#  struct sockaddr_storage local_addr; /* local address */
+#  struct sockaddr_storage remote_addr;/* remote address */
 #  char *remote_ip;		/* Client's IP address */
 #  char *remote_host;		/* Client's DNS name, if known.
 #                                 * NULL if DNS hasn't been checked,
@@ -78,7 +78,7 @@ remote_addr(conn, sv_addr=Nullsv)
     RETVAL = newSVpv((char *)&conn->remote_addr,
                       sizeof conn->remote_addr);
     if(sv_addr) {
-        struct sockaddr_in addr; 
+        struct sockaddr_storage addr; 
         STRLEN sockaddrlen; 
         char * new_addr = SvPV(sv_addr,sockaddrlen); 
         if (sockaddrlen != sizeof(addr)) { 
@@ -97,7 +97,9 @@ remote_ip(conn, ...)
 
     CODE:
     RETVAL = conn->remote_ip;
- 
+
+    struct addrinfo rhints, *res, *res0;
+    int error;
     if(items > 1) {
 #ifdef SGI_BOOST
         ap_cpystrn(conn->remote_ip, (char *)SvPV(ST(1),na),
@@ -106,7 +108,18 @@ remote_ip(conn, ...)
 #else
         conn->remote_ip = pstrdup(conn->pool, (char *)SvPV(ST(1),na));
 #endif
-        conn->remote_addr.sin_addr.s_addr = inet_addr(conn->remote_ip);
+        memset(&rhints, 0, sizeof(rhints));
+        rhints.ai_family = PF_UNSPEC;
+        rhints.ai_socktype = SOCK_STREAM;
+        error = getaddrinfo(conn->remote_ip, NULL, &rhints, &res0);
+        if (!error) {
+            memcpy(&conn->remote_addr, (const void *)res0->ai_addr,
+                (size_t) res0->ai_addrlen);
+            freeaddrinfo(res0);
+        } else {
+            croak("Bad IP address in remote_ip getaddrinfo failed %s",
+                gai_strerror(error));
+        }
     }
 
     OUTPUT:
